/************************************************************************************
FileName : cgi_impl.h
Description : Exported interface for Cgi Interface SDK
Caution: Never start this CGI daemon in different threads!!!
         Never start this CGI daemon twice!!!
************************************************************************************/

#ifndef __CGI_IMPL_H__
#define __CGI_IMPL_H__


#define USE_DEFAULT_CGI_PORT	0

#define CGI_SUCCESS				0
#define CGI_ERROR_THD			1	// failed to create thread
#define CGI_ALREADY_WORKING		2
#define CGI_NOT_WORKING			3
#define CGI_WRONG_PARAM			4

typedef int (*process_cgi_cmd)(unsigned char * buf, int buf_len, int sock, unsigned short cmd);

/*
 * Interface function: start_cgi_daemon
 * Description:	Set callback routine for the process of received CGI commands
 ****************************************************************************
 * @Param: 
 * @Return: 0 if success, otherwise error code 
 */
int start_cgi_daemon(process_cgi_cmd p_func, int cgi_port);

/*
 * Interface function: stop_cgi_daemon
 * Description:	Stop the entire CGI daemon.
 ****************************************************************************
 * @Param: None
 * @Return: 0 if success, otherwise error code 
 */
int stop_cgi_daemon();

#endif